var fs=require('fs');



/* //readStream
var alldata='';
var readStream=fs.createReadStream('buffer.js');
readStream.setEncoding('UTF8');

var recvHandle=function(data)
{
	console.log('recv>>len:'+data.length);
	alldata+=data;
};


var endHandle=function()
{
	console.log('end>> len:'+alldata.length+',content:',alldata.toString());
};


var errorHandle=function(err)
{
	console.log('ERROR>>'+err.stack);
	
};

readStream.on('data',recvHandle);
readStream.on('end',endHandle);
readStream.on('error',errorHandle);


//writeStream
var buf="i want to write something...";
var finishHandle=function()
{
	console.log('finish>> len:'+buf.length+',content:',buf.toString());
};


var errorHandle=function(err)
{
	console.log('ERROR>>'+err.stack);
	
};

var writeStream=fs.createWriteStream('outStream.txt');
writeStream.write(buf,'UTF8');
writeStream.end();
writeStream.on('finish',finishHandle);
writeStream.on('error',errorHandle);
console.log("finish!"); */



//pipe
var rStream=fs.createReadStream('sds.txt');
var wStream=fs.createWriteStream('copy.txt');
rStream.pipe(wStream);
console.log('finish');
